<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>李宁体育</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="<%=path%>/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path%>/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="<%=path%>/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="<%=path%>/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="<%=path%>/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="<%=path%>/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="<%=path%>/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="<%=path%>/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"
          rel="stylesheet">
    <link href="<%=path%>/css/animate.min.css" rel="stylesheet">
    <link href="<%=path%>/css/style.min862f.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg" onload="checkVote();">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>新建投票问题</h5>               
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" action="saveVipVote.do" method="post" id="vipVoteForm" enctype="multipart/form-data">
                        <div class="form-group">
                            <input type="hidden" id="activityId" name="activityId" value="${activityId}"></input>
                            <input type="hidden" id="vote" name="vote"></input>                                
							<label class="col-sm-2 control-label">标题</label><font color="red">*</font>
							<div class="col-sm-3">
								<input type="text" class="form-control" name="title" id="title" maxlength="12"  placeholder="请填写问题的标题"></input>
							</div>
						</div>						
						<div class="form-group">
							<label class="col-sm-2 control-label"></label>
							<div class="col-sm-3">
								<input type="radio"  name="type" id="type" value="1" checked="checked"></input>&nbsp;&nbsp;单选
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio"  name="type" id="type" value="2"></input>&nbsp;&nbsp;多选
							</div>
						</div>
						<!-- <div id="voteId">						
						<div class="form-group">
							<label class="col-sm-2 control-label"></label>
							<div class="col-sm-3">
								<input type="text" id="vote" name="vote" class="form-control"></input>  
							</div>
						</div>
						</div> -->
						<div class="form-group">
							<label class="col-sm-2 control-label"></label><font color="red"></font>
							<div class="col-sm-3">
								<a href="#" id="AddMoreFileBox" class="btn btn-info">添加选项</a>
							</div>
							<span id="errWt" style="color: red;"></span>
						</div>
						<div id="InputsWrapper"> 									  
						</div>
									
						<div class="form-group">
                             <div class="col-sm-4 col-sm-offset-3">
                              <button class="btn btn-primary" type="submit" onclick="subVipVote();">完 成</button>
                              <!-- &nbsp;<button class="btn btn-info" type="button" onclick="goBackVipActivity()">返  回</button>  -->                                  
                             </div>
                        </div>                                                         
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="<%=path%>/js/jquery.min.js?v=2.1.4"></script>
<script src="<%=path%>/js/bootstrapValidator.min.js"></script>
<!--下拉框-->
<script src="<%=path%>/js/plugins/chosen/chosen.jquery.js"></script>
<script>
    $(document).ready(function() {  
    var txtarr = ['一','二','三','四','五','六','七','八','九','十']
    var resetOptOrder = function () {
		var ellist = $("#InputsWrapper .form-group .control-label");
		for (var ii=0; ii<ellist.length; ii++) {
			ellist.eq(ii).html('选项'+txtarr[ii]);
		}
	}
	var MaxInputs = 9; 
	var InputsWrapper = $("#InputsWrapper");  
	var AddButton = $("#AddMoreFileBox"); 	  
	var x = InputsWrapper.length;  
	var FieldCount=1;  	  
	$(AddButton).click(function (e)  
	{  
	        if(x <= MaxInputs)   
	        {  
	            FieldCount++; 	            
	            $(InputsWrapper).append('<div class="form-group"><label class="col-sm-2 control-label">选项'+txtarr[x - 1]+'</label><div class="col-sm-3"><input type="text"  name="wt['+(x - 1)+']" id="wt_'+ FieldCount +'" class="form-control"/></input><input id="pictureTwo" name="picture" type="file"  maxlength="32" title="图片" placeholder="图片"/><a href="#" class="removeclass">删 除</a>&nbsp;&nbsp;&nbsp;&nbsp;<span id="imgHint" style="color:red">图片比例1:1，建议尺寸120x120px</span></div></div></div>');  
	            x++; 
	            resetOptOrder()
	        }  
	return false;  
	});  	  
	$("body").on("click",".removeclass", function(e){
	        if( x > 1 ) {  
	                $(this).parents('.form-group').remove();
	                resetOptOrder();
	                x--; 
	                FieldCount--;
	}  
	return false;  
	})   
	  
	}); 
    //表单验证
    var config = {
            ".chosen-select": {},
            ".chosen-select-deselect": {allow_single_deselect: !0},
            ".chosen-select-no-single": {disable_search_threshold: 10},
            ".chosen-select-no-results": {no_results_text: "Oops, nothing found!"},
            ".chosen-select-width": {width: "95%"}
    };
    
    for (var selector in config)$(selector).chosen(config[selector]);
    $(document).ready(function () {
        $('#vipVoteForm').bootstrapValidator({
            message: 'This value is not valid',
            fields: {
            	title: {
                    message: '标题不能为空！',
                    validators: {
                        notEmpty: {
                            message: '标题不能为空！'
                        }
                    }
                },
                /* picture: {
                    message: '请选择问题！',
                    validators: {
                        notEmpty: {
                            message: '请选择问题！'
                        }
                    }
                }, */
            },
            submitHandler: function(validator, form, submitButton) {
            }
        });
    });
    function subVipVote() {
    	var activityId = $("#activityId").val();
    	var fromarr = $('#InputsWrapper input[type=text]')
    	var fromobj = '';
    	for(var fii=0; fii<fromarr.length; fii++) {
    		fromobj += fromarr.eq(fii).val() + ','
    	}
    	$("#vote").val(fromobj.substring(0,fromobj.length-1));    	
	} 
    
    <%-- function goBackVipActivity() {
        var activityId = $("#activityId").val();
    	window.location.href="<%=basePath%>vipActivity/queryVipVoteList.do?activityId="+activityId;
    	window.location.href= "<%=path%>/vipActivity/saveVipVote?activityId="+activityId+"&vote="+fromobj.substring(0,fromobj.length-1);
    }  --%>
</script>
</body>
</html>
